<?php
echo CHtml::hiddenField('parentId', $parentId);
?>

<ul id="sortable" class="childMenu" style="font-size: 1.2em;">
    <?php
    if (!empty($menu)) {
        foreach ($menu as $id => $title) {
            echo '<li id="orderid_' . $id . '">';
            echo '<span class="handle float-left ui-icon ui-icon-arrow-4"></span>';
            echo CHtml::link($title, array('menu/update', 'id' => $id), array(
                'class' => 'updateContent',
            ));

            $label = Yii::t('DadminModule.app', 'delete');
            echo CHtml::link("($label)", array('menu/delete', 'id' => $id), array(
                'class' => 'link deleteMenu',
                'style' => 'margin:0 5px;',
                )
            );
            echo '</li>';
        }
    }
    ?>
</ul>

<div>
    <a href="javascript:void(0)"
       id="createContent"
       class="btn ui-state-default ui-corner-all" 
       style="margin-left:0;">
        <span class="ui-icon ui-icon-plus"></span><?php echo Yii::t('DadminModule.app', 'add'); ?>
    </a>
</div>

<script type="text/javascript">
    //Sort Menu (child)
    $("#sortable").sortable({
        handle : '.handle',
        update : function () {
            order = $('#sortable').sortable("serialize");
            url = '<?php echo $this->createUrl('menu/menuUpdateOrder'); ?>';

            $.ajax({
                type: 'POST',
                url: url,
                data: order,
                cache: false,
                success: function(html) {
                    loadMenu();
                }
            });
        }
    });
</script>